package com.ss.android.article.base.feature.detail2.article.b;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import com.bytedance.frameworks.base.mvp.Presenter;
import com.ss.android.account.c.QZone;
import com.ss.android.article.base.feature.detail.presenter.CommentFetcher;
import com.ss.android.article.base.feature.detail2.article.a.NewDetailViewHolder;
import com.ss.android.article.base.feature.detail2.article.c.NewDetailView;
import com.ss.android.article.base.feature.detail2.c.NewArticleDetailTTAndroidObject;
import com.ss.android.article.base.feature.detail2.d.DetailLoadResultHandler;
import com.ss.android.article.base.feature.detail2.d.NewDetailContext;
import com.ss.android.article.base.feature.detail2.e.a.CommonBizInteractor;
import com.ss.android.article.common.share.log.BaseQZoneShareListener;

public final class ArticleDetailCommentPresenter extends Presenter {
    public NewDetailContext mNewDetailContext;
    public DetailLoadResultHandler mDetailLoadResultHandler;
    public DetailWebInteractor mDetailWebInteractor;
    private CommonBizInteractor mCommonBizInteractor;
    private WebActionInteractor mWebActionInteractor;

    public ArticleDetailCommentPresenter(Context context,
                                         NewDetailContext newDetailContext,
                                         NewDetailViewHolder newDetailViewHolder,
                                         CommonBizInteractor arg10) {
        super(context);
        this.mNewDetailContext = newDetailContext;
        this.mDetailLoadResultHandler = new DetailLoadResultHandler(this.mContext, newDetailContext);
        this.mCommonBizInteractor = arg10;
        if (this.mCommonBizInteractor != null) {
            this.addInteractor(this.mCommonBizInteractor);
        }

        this.mWebActionInteractor = new WebActionInteractor(context, this.mNewDetailContext, newDetailViewHolder);
        this.addInteractor(this.mWebActionInteractor);
        this.mDetailWebInteractor = new DetailWebInteractor(context, this.mNewDetailContext, newDetailViewHolder, this.mDetailLoadResultHandler, this.mWebActionInteractor);
        this.addInteractor(this.mDetailWebInteractor);
    }

    public final void loadComment(String itemKey, CommentFetcher commentFetcher) {
        mDetailLoadResultHandler.mCommentResultListener = new DetailLoadResultHandler.ResultListener<CommentFetcher, Boolean>() {

            public final void onResult(CommentFetcher fetcher, Boolean arg4) {
                if (ArticleDetailCommentPresenter.this.hasView()) {
                    ((NewDetailView) ArticleDetailCommentPresenter.this.mView).onCommentLoaded(fetcher, arg4.booleanValue());
                }
            }
        };
        mDetailLoadResultHandler.mDetailLoader.loadComment(itemKey, commentFetcher);
    }

    public final void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (this.mCommonBizInteractor != null) {
            if (!QZone.onShareToQQResult(requestCode, resultCode, data, new BaseQZoneShareListener(this.mCommonBizInteractor.mContext, false))) {
                QZone.onShareToQQResult(requestCode, resultCode, data, new BaseQZoneShareListener(this.mCommonBizInteractor.mContext, true), true);
            }
        }
        if (mDetailWebInteractor.mDetailWebChromeClient != null) {
            mDetailWebInteractor.mDetailWebChromeClient.onActivityResult(requestCode, resultCode, data);
        }
    }

    public final void onCreate(Bundle bundle, Bundle arg2) {
        super.onCreate(bundle, arg2);
    }

    public final void onResume() {
        super.onResume();
        this.mDetailLoadResultHandler.mDetailLoader.onResume();
        this.mDetailWebInteractor.mNewArticleDetailTTAndroidObject.onResume();
    }

    public final void onPause() {
        super.onPause();
        this.mDetailLoadResultHandler.mDetailLoader.onPause();
        NewArticleDetailTTAndroidObject.e();
    }

    public final void onDestroy() {
        super.onDestroy();
        this.mDetailLoadResultHandler.mDetailLoader.onDestroy();
        this.mDetailWebInteractor.mNewArticleDetailTTAndroidObject.b();
    }
}

